package cryptx

import (
	"codeup.aliyun.com/lsxd/zltx/adapter/utils/cryptx/rsa"
	"codeup.aliyun.com/lsxd/zltx/adapter/utils/formater"
)

type rsaBuilder struct {
	base *rsa.Options
}

// SetFormat 设置数据格式 default Base64
func (b *rsaBuilder) SetFormat(f formater.Formater) *rsaBuilder {
	b.base.SetFormat(f)
	return b
}

// SetPrivateKey 设置私钥
func (b *rsaBuilder) SetPrivateKey(prk string) *rsaBuilder {
	b.base.SetPrivateKey(prk)
	return b
}

// SetPublicKey 设置公钥
func (b *rsaBuilder) SetPublicKey(pk string) *rsaBuilder {
	b.base.SetPublicKey(pk)
	return b
}

// SetKeyType 设置密钥类型，default PKCS1
func (b *rsaBuilder) SetKeyType(kt rsa.KeyType) *rsaBuilder {
	b.base.SetKeyType(kt)
	return b
}

// SetReversion 设置是否使用反向加密，default false
func (b *rsaBuilder) SetReversion(r bool) *rsaBuilder {
	b.base.SetReversion(r)
	return b
}

// Build 构建加密器
func (b *rsaBuilder) Build() Crypto {
	d := rsa.NewRsa(b.base)
	return d
}
